<template>
  <div class="row justify-content-center">
    <div class="col-8">
      <form name="editForm" role="form" novalidate v-on:submit.prevent="save()">
        <h2 id="roomAdminApp.roomFile.home.createOrEditLabel" data-cy="RoomFileCreateUpdateHeading">Create or edit a RoomFile</h2>
        <div>
          <div class="form-group" v-if="roomFile.id">
            <label for="id">ID</label>
            <input type="text" class="form-control" id="id" name="id" v-model="roomFile.id" readonly />
          </div>
          <div class="form-group">
            <label class="form-control-label" for="room-file-fileName">File Name</label>
            <input
              type="text"
              class="form-control"
              name="fileName"
              id="room-file-fileName"
              data-cy="fileName"
              :class="{ valid: !$v.roomFile.fileName.$invalid, invalid: $v.roomFile.fileName.$invalid }"
              v-model="$v.roomFile.fileName.$model"
            />
            <div v-if="$v.roomFile.fileName.$anyDirty && $v.roomFile.fileName.$invalid">
              <small class="form-text text-danger" v-if="!$v.roomFile.fileName.maxLength">
                This field cannot be longer than 50 characters.
              </small>
            </div>
          </div>
          <div class="form-group">
            <label class="form-control-label" for="room-file-fileExt">File Ext</label>
            <input
              type="text"
              class="form-control"
              name="fileExt"
              id="room-file-fileExt"
              data-cy="fileExt"
              :class="{ valid: !$v.roomFile.fileExt.$invalid, invalid: $v.roomFile.fileExt.$invalid }"
              v-model="$v.roomFile.fileExt.$model"
            />
            <div v-if="$v.roomFile.fileExt.$anyDirty && $v.roomFile.fileExt.$invalid">
              <small class="form-text text-danger" v-if="!$v.roomFile.fileExt.maxLength">
                This field cannot be longer than 10 characters.
              </small>
            </div>
          </div>
          <div class="form-group">
            <label class="form-control-label" for="room-file-fileType">File Type</label>
            <input
              type="text"
              class="form-control"
              name="fileType"
              id="room-file-fileType"
              data-cy="fileType"
              :class="{ valid: !$v.roomFile.fileType.$invalid, invalid: $v.roomFile.fileType.$invalid }"
              v-model="$v.roomFile.fileType.$model"
            />
            <div v-if="$v.roomFile.fileType.$anyDirty && $v.roomFile.fileType.$invalid">
              <small class="form-text text-danger" v-if="!$v.roomFile.fileType.maxLength">
                This field cannot be longer than 32 characters.
              </small>
            </div>
          </div>
          <div class="form-group">
            <label class="form-control-label" for="room-file-imageType">Image Type</label>
            <input
              type="text"
              class="form-control"
              name="imageType"
              id="room-file-imageType"
              data-cy="imageType"
              :class="{ valid: !$v.roomFile.imageType.$invalid, invalid: $v.roomFile.imageType.$invalid }"
              v-model="$v.roomFile.imageType.$model"
            />
            <div v-if="$v.roomFile.imageType.$anyDirty && $v.roomFile.imageType.$invalid">
              <small class="form-text text-danger" v-if="!$v.roomFile.imageType.maxLength">
                This field cannot be longer than 32 characters.
              </small>
            </div>
          </div>
          <div class="form-group">
            <label class="form-control-label" for="room-file-fileRemark">File Remark</label>
            <input
              type="text"
              class="form-control"
              name="fileRemark"
              id="room-file-fileRemark"
              data-cy="fileRemark"
              :class="{ valid: !$v.roomFile.fileRemark.$invalid, invalid: $v.roomFile.fileRemark.$invalid }"
              v-model="$v.roomFile.fileRemark.$model"
            />
          </div>
          <div class="form-group">
            <label class="form-control-label" for="room-file-fileGroup">File Group</label>
            <input
              type="text"
              class="form-control"
              name="fileGroup"
              id="room-file-fileGroup"
              data-cy="fileGroup"
              :class="{ valid: !$v.roomFile.fileGroup.$invalid, invalid: $v.roomFile.fileGroup.$invalid }"
              v-model="$v.roomFile.fileGroup.$model"
            />
            <div v-if="$v.roomFile.fileGroup.$anyDirty && $v.roomFile.fileGroup.$invalid">
              <small class="form-text text-danger" v-if="!$v.roomFile.fileGroup.maxLength">
                This field cannot be longer than 32 characters.
              </small>
            </div>
          </div>
          <div class="form-group">
            <label class="form-control-label" for="room-file-filePath">File Path</label>
            <input
              type="text"
              class="form-control"
              name="filePath"
              id="room-file-filePath"
              data-cy="filePath"
              :class="{ valid: !$v.roomFile.filePath.$invalid, invalid: $v.roomFile.filePath.$invalid }"
              v-model="$v.roomFile.filePath.$model"
            />
          </div>
          <div class="form-group">
            <label class="form-control-label" for="room-file-createdBy">Created By</label>
            <input
              type="text"
              class="form-control"
              name="createdBy"
              id="room-file-createdBy"
              data-cy="createdBy"
              :class="{ valid: !$v.roomFile.createdBy.$invalid, invalid: $v.roomFile.createdBy.$invalid }"
              v-model="$v.roomFile.createdBy.$model"
            />
            <div v-if="$v.roomFile.createdBy.$anyDirty && $v.roomFile.createdBy.$invalid">
              <small class="form-text text-danger" v-if="!$v.roomFile.createdBy.maxLength">
                This field cannot be longer than 32 characters.
              </small>
            </div>
          </div>
          <div class="form-group">
            <label class="form-control-label" for="room-file-createdDate">Created Date</label>
            <div class="d-flex">
              <input
                id="room-file-createdDate"
                data-cy="createdDate"
                type="datetime-local"
                class="form-control"
                name="createdDate"
                :class="{ valid: !$v.roomFile.createdDate.$invalid, invalid: $v.roomFile.createdDate.$invalid }"
                :value="convertDateTimeFromServer($v.roomFile.createdDate.$model)"
                @change="updateInstantField('createdDate', $event)"
              />
            </div>
          </div>
          <div class="form-group">
            <label class="form-control-label" for="room-file-lastModifiedBy">Last Modified By</label>
            <input
              type="text"
              class="form-control"
              name="lastModifiedBy"
              id="room-file-lastModifiedBy"
              data-cy="lastModifiedBy"
              :class="{ valid: !$v.roomFile.lastModifiedBy.$invalid, invalid: $v.roomFile.lastModifiedBy.$invalid }"
              v-model="$v.roomFile.lastModifiedBy.$model"
            />
            <div v-if="$v.roomFile.lastModifiedBy.$anyDirty && $v.roomFile.lastModifiedBy.$invalid">
              <small class="form-text text-danger" v-if="!$v.roomFile.lastModifiedBy.maxLength">
                This field cannot be longer than 32 characters.
              </small>
            </div>
          </div>
          <div class="form-group">
            <label class="form-control-label" for="room-file-lastModifiedDate">Last Modified Date</label>
            <div class="d-flex">
              <input
                id="room-file-lastModifiedDate"
                data-cy="lastModifiedDate"
                type="datetime-local"
                class="form-control"
                name="lastModifiedDate"
                :class="{ valid: !$v.roomFile.lastModifiedDate.$invalid, invalid: $v.roomFile.lastModifiedDate.$invalid }"
                :value="convertDateTimeFromServer($v.roomFile.lastModifiedDate.$model)"
                @change="updateInstantField('lastModifiedDate', $event)"
              />
            </div>
          </div>
        </div>
        <div>
          <button type="button" id="cancel-save" data-cy="entityCreateCancelButton" class="btn btn-secondary" v-on:click="previousState()">
            <font-awesome-icon icon="ban"></font-awesome-icon>&nbsp;<span>Cancel</span>
          </button>
          <button
            type="submit"
            id="save-entity"
            data-cy="entityCreateSaveButton"
            :disabled="$v.roomFile.$invalid || isSaving"
            class="btn btn-primary"
          >
            <font-awesome-icon icon="save"></font-awesome-icon>&nbsp;<span>Save</span>
          </button>
        </div>
      </form>
    </div>
  </div>
</template>
<script lang="ts" src="./room-file-update.component.ts"></script>
